package cz.cuni.mff.d3s.alloy.mockup;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.layout.grouplayout.GroupLayout;
import org.eclipse.swt.custom.CBanner;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import swing2swt.layout.BorderLayout;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.widgets.Text;
import com.swtdesigner.SWTResourceManager;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.swt.widgets.CoolBar;
import org.eclipse.swt.widgets.CoolItem;

public class MainWindow {

	protected Shell shlAlloyAnalyzerMockup;

	/**
	 * Launch the application.
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			MainWindow window = new MainWindow();
			window.open();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Open the window.
	 */
	public void open() {
		Display display = Display.getDefault();
		createContents();
		shlAlloyAnalyzerMockup.open();
		shlAlloyAnalyzerMockup.layout();
		while (!shlAlloyAnalyzerMockup.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

	/**
	 * Create contents of the window.
	 */
	protected void createContents() {
		shlAlloyAnalyzerMockup = new Shell();
		shlAlloyAnalyzerMockup.setSize(673, 514);
		shlAlloyAnalyzerMockup.setText("Alloy Analyzer Mockup");
		shlAlloyAnalyzerMockup.setLayout(new BorderLayout(0, 0));
		
		Menu menu = new Menu(shlAlloyAnalyzerMockup, SWT.BAR);
		shlAlloyAnalyzerMockup.setMenuBar(menu);
		
		MenuItem mntmFile = new MenuItem(menu, SWT.CASCADE);
		mntmFile.setText("File");
		
		Menu menu_1 = new Menu(mntmFile);
		mntmFile.setMenu(menu_1);
		
		MenuItem mntmQuit = new MenuItem(menu_1, SWT.NONE);
		mntmQuit.setText("Quit");
		
		SashForm sashForm = new SashForm(shlAlloyAnalyzerMockup, SWT.NONE);
		sashForm.setLayoutData(BorderLayout.CENTER);
		
		SashForm sashForm_1 = new SashForm(sashForm, SWT.NONE);
		sashForm_1.setOrientation(SWT.VERTICAL);
		
		TabFolder tabFolder = new TabFolder(sashForm_1, SWT.NONE);
		
		TabItem tbtmMyModule = new TabItem(tabFolder, SWT.NONE);
		tbtmMyModule.setText("My Module");
		
		ScrolledComposite scrolledComposite_1 = new ScrolledComposite(tabFolder, SWT.H_SCROLL | SWT.V_SCROLL);
		tbtmMyModule.setControl(scrolledComposite_1);
		scrolledComposite_1.setExpandHorizontal(true);
		scrolledComposite_1.setExpandVertical(true);
		
		StyledText styledText = new StyledText(scrolledComposite_1, SWT.BORDER);
		scrolledComposite_1.setContent(styledText);
		scrolledComposite_1.setMinSize(styledText.computeSize(SWT.DEFAULT, SWT.DEFAULT));
		
		TabItem tbtmModule = new TabItem(tabFolder, SWT.NONE);
		tbtmModule.setText("Module 2");
		
		StyledText styledText_2 = new StyledText(tabFolder, SWT.BORDER);
		tbtmModule.setControl(styledText_2);
		
		ScrolledComposite scrolledComposite_2 = new ScrolledComposite(sashForm_1, SWT.H_SCROLL | SWT.V_SCROLL);
		scrolledComposite_2.setExpandHorizontal(true);
		scrolledComposite_2.setExpandVertical(true);
		
		StyledText styledText_1 = new StyledText(scrolledComposite_2, SWT.BORDER);
		styledText_1.setEditable(false);
		styledText_1.setText("Executing \"Run run$1 for 0 but 6 LLCEI, 1 RS, 2 RSR, 2 RSEntry\"\n   Solver=sat4j Bitwidth=4 MaxSeq=0 SkolemDepth=1 Symmetry=20\n   6788 vars. 257 primary vars. 12782 clauses. 187ms.\n   . found. Predicate is consistent. 87ms.\n\nExecuting \"Run run$1 for 0 but 6 LLCEI, 1 RS, 2 RSR, 2 RSEntry\"\n   Solver=sat4j Bitwidth=4 MaxSeq=0 SkolemDepth=1 Symmetry=20\n   6788 vars. 257 primary vars. 12782 clauses. 187ms.\n   . found. Predicate is consistent. 87ms.\n\nExecuting \"Run run$1 for 0 but 6 LLCEI, 1 RS, 2 RSR, 2 RSEntry\"\n   Solver=sat4j Bitwidth=4 MaxSeq=0 SkolemDepth=1 Symmetry=20\n   6788 vars. 257 primary vars. 12782 clauses. 187ms.\n   . found. Predicate is consistent. 87ms.");
		styledText_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		scrolledComposite_2.setContent(styledText_1);
		scrolledComposite_2.setMinSize(styledText_1.computeSize(SWT.DEFAULT, SWT.DEFAULT));
		sashForm_1.setWeights(new int[] {322, 136});
		
		SashForm sashForm_2 = new SashForm(sashForm, SWT.VERTICAL);
		
		Tree tree = new Tree(sashForm_2, SWT.BORDER);
		tree.setHeaderVisible(true);
		
		TreeItem trtmThisModule = new TreeItem(tree, SWT.NONE);
		trtmThisModule.setText("this module");
		
		TreeItem trtmSigA = new TreeItem(trtmThisModule, SWT.NONE);
		trtmSigA.setText("sig A");
		
		TreeItem trtmSigB_1 = new TreeItem(trtmThisModule, SWT.NONE);
		trtmSigB_1.setText("sig B");
		
		TreeItem trtmPredP_2 = new TreeItem(trtmThisModule, SWT.NONE);
		trtmPredP_2.setText("pred P");
		
		TreeItem trtmRun_1 = new TreeItem(trtmThisModule, SWT.NONE);
		trtmRun_1.setText("run1");
		trtmThisModule.setExpanded(true);
		
		TreeItem trtmSigB = new TreeItem(tree, 0);
		trtmSigB.setText("Module 2");
		
		TreeItem trtmSigA_1 = new TreeItem(trtmSigB, SWT.NONE);
		trtmSigA_1.setText("sig A2");
		
		TreeItem trtmSigB_2 = new TreeItem(trtmSigB, SWT.NONE);
		trtmSigB_2.setText("sig B2");
		
		TreeItem trtmInstances_1 = new TreeItem(trtmSigB, SWT.NONE);
		trtmInstances_1.setText("Instances");
		
		TreeItem trtmInstance = new TreeItem(trtmInstances_1, SWT.NONE);
		trtmInstance.setText("Instance 1");
		
		TreeItem trtmInstance_1 = new TreeItem(trtmInstances_1, SWT.NONE);
		trtmInstance_1.setText("Instance 2");
		trtmInstances_1.setExpanded(true);
		trtmSigB.setExpanded(true);
		
		TreeColumn trclmnModuleExplorer = new TreeColumn(tree, SWT.NONE);
		trclmnModuleExplorer.setWidth(100);
		trclmnModuleExplorer.setText("Module Explorer");
		
		Tree tree_1 = new Tree(sashForm_2, SWT.BORDER);
		tree_1.setHeaderVisible(true);
		
		TreeItem trtmItem = new TreeItem(tree_1, SWT.NONE);
		trtmItem.setText("Item");
		
		TreeColumn trclmnModelExplorer = new TreeColumn(tree_1, SWT.LEFT);
		trclmnModelExplorer.setWidth(100);
		trclmnModelExplorer.setText("Model Explorer");
		sashForm_2.setWeights(new int[] {1, 1});
		sashForm.setWeights(new int[] {333, 221});
		
		ToolBar toolBar = new ToolBar(shlAlloyAnalyzerMockup, SWT.FLAT | SWT.RIGHT);
		toolBar.setLayoutData(BorderLayout.NORTH);
		
		ToolItem tltmExecute = new ToolItem(toolBar, SWT.NONE);
		tltmExecute.setText("Execute");

	}
}
